﻿package  {
	
	import flash.display.MovieClip;
	
	
	public class Vertex extends MovieClip {
		public var kolor:int = 0;
		public var numer:int = 0;
		public var polaczenia:Array = new Array();
		public var joined:Boolean = false;
		private var rootR:*;
		
		public function Vertex(dane:String, rootR:*) {
			this.rootR = rootR;
			var pomoc:Array = new Array();
			
			pomoc = dane.split("|");
			//trace(pomoc);
			kolor = pomoc[1];
			numer = pomoc[0];
			polaczenia = pomoc[2].split("&");
			trace(polaczenia);
			trace(numer)
			trace(kolor);
			trace("----------");
			this.gotoAndStop(kolor);
			this.x = Math.random() * 950;
			this.y = Math.random() * 650;
			
			// constructor code
			
		}
		public function rysujLaczenia() {
			var tabRef:* = this.rootR.vertexTab;
			for(var i:int=0; i<polaczenia.length; i++) {
				var vertId:int = int(polaczenia[i]);
				if(tabRef[vertId].joined==false) {
				   
				   
				this.rootR.joinThem(this, tabRef[vertId]);
				   }
			}
			joined=true;
			
		}
	}
	
}
